package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * PROJECT_NAME: sky-take-out
 * NAME: ShopController
 *
 * @AUTHOR: zhang
 * DATE: 2023/11/28
 * DESCRIPTION :
 */
@Slf4j
@Api(tags = "C端-营业状态信息表现层接口") //@Api:用户描述类的相关信息
@RestController("userShopController")
@RequestMapping("/user/shop")
public class ShopController {
    @Resource
    private RedisTemplate redisTemplate;

    public static final String SHOP_STATUS="SHOP_STATUS";

    @ApiOperation("获取店铺状态")
    @GetMapping("/status")
    public Result getShopStatus(){
        Integer shopStatus = (Integer) redisTemplate.opsForValue().get(SHOP_STATUS);
        log.info("获取到店铺的营业状态为：{}",shopStatus == 1 ? "营业中" : "打烊中");
        return Result.success(shopStatus);
    }
}
